from selenium import webdriver
from selenium.webdriver.common.by import By
import time


driver = webdriver.Edge()

url = "https://www.baidu.com/"

driver.get(url)

# 窗口最大化
driver.maximize_window()
time.sleep(3)
# 自定义窗口大小
driver.set_window_size(1000,800)
time.sleep(3)
# 移动浏览器位置
driver.set_window_position(100,100)

# 操作
driver.find_element(By.XPATH,"//*[@name='wd']").send_keys("lyr")
# 获取浏览器标题
print(driver.title)
time.sleep(3)
driver.find_element(By.XPATH,"//*[@id='su']").click()

time.sleep(3)
# 获取当前网址url
print(driver.current_url)

# 浏览器回退
driver.back()
print(driver.current_url)

time.sleep(1)
# 浏览器前进
# driver.forward()
# time.sleep(2)
# 浏览器刷新
driver.refresh()

driver.find_element(By.PARTIAL_LINK_TEXT,"hao123").click()
driver.close()

time.sleep(3)
# 浏览器退出
driver.quit()